package com.ybxx.asset.service.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.ybxx.asset.dao.LandDao;
import com.ybxx.asset.model.Land;
import com.ybxx.asset.model.Trench;
import com.ybxx.asset.service.LandService;
import com.ybxx.core.command.QueryFilter;
import com.ybxx.core.dao.GenericDao;
import com.ybxx.core.service.impl.BaseServiceImpl;
import com.ybxx.core.web.paging.PagingBean;

public class LandServiceImpl extends BaseServiceImpl<Land> implements
		LandService {
	private LandDao landDao;
	public LandServiceImpl(LandDao dao) {
		super(dao);
		this.landDao=dao;
		// TODO Auto-generated constructor stub
	}
	public List<Land> queryPage(Land land, QueryFilter filter) {
		String hql="from Land l where 1=1 ";
		if(land!=null && StringUtils.isNotEmpty(land.getTdzh())){
			hql+=" and l.tdzh like '%"+land.getTdzh()+"%'";
		}
		if(land!=null && StringUtils.isNotEmpty(land.getLname())){
			hql+=" and l.lname like '%"+land.getLname()+"%'";
		}
		if(land!=null && StringUtils.isNotEmpty(land.getMdept())){
			hql+=" and l.mdept like '%"+land.getMdept()+"%'";
		}
		
		return landDao.findByHql(hql, null, filter.getPagingBean());
	}
	public List<Land> exportExcel_Print(Land land) {
		String hql="from Land l left join fetch l.company c where 1=1 ";
		if(land!=null && StringUtils.isNotEmpty(land.getTdzh())){
			hql+=" and l.tdzh like '%"+land.getTdzh()+"%'";
		}
		if(land!=null && StringUtils.isNotEmpty(land.getLname())){
			hql+=" and l.lname like '%"+land.getLname()+"%'";
		}
		if(land!=null && StringUtils.isNotEmpty(land.getMdept())){
			hql+=" and l.mdept like '%"+land.getMdept()+"%'";
		}
		
		return landDao.findByHql(hql, null);
	}
	@Override
	public Land get(String id) {
		String hql="from Land l left join fetch l.company c where lid='"+id+"' ";
		return (Land)landDao.findUnique(hql, null);
	}
}

